<?php
class Location extends LocationPeer
{
	function Location()
	{
		parent::LocationPeer();
	}

	
	
	public static function getAllLocations($active=1, $country_id=NULL)
	{
		$db = new Database();
		if ($active != 1)
			$active = 0;
		$query = "SELECT id FROM location WHERE active=$active ";
		if ($country_id)
			$query .= " AND country=$country_id";
		$result = $db->query($query);
		
		$ids = $db->fetch_array($result);

		$locations = array();

		foreach ($ids as $id) {
			$location = new Location();
			$location->select($id['id']);			
			$locations[] = $location;
		}
		
		return $locations;
	}
	
	function getAllPictures()
	{
		$picture_ids = $this->getpictures();
		$picture_ids = json_decode($picture_ids, true);
		$pictures = array();
		if ($picture_ids)
			foreach ($picture_ids as $id) 
				if ($id) {
				$pic = new Picture();
				$pic->select($id);
				$pictures[] = $pic;
			}
		
		return $pictures;
	}

}
?>